package com.travelSpring.controller;

import com.github.pagehelper.PageInfo;
import com.travelSpring.common.Result;
import com.travelSpring.entity.User;
import com.travelSpring.service.UserService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 功能：
 * 作者：卷心菜
 * 日期：2025/3/1 18:50
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    UserService userService;

    @GetMapping("/selectAll")
    public Result selectAll(){
        List<User> users = userService.selectAll();
        return Result.success(users);
    }

    @GetMapping("/selectPage")
    public Result selectPage(@RequestParam(defaultValue = "10") Integer pageSize,
                             @RequestParam(defaultValue = "1") Integer pageNum,
                             User user){
        PageInfo ans=userService.selectPage(pageSize,pageNum,user);
        return Result.success(ans);
    }
}
